<template>
    <orh-table reload @on-reload="refresh (pageDate.current_page)" search @on-search="searchmt" pages :pageDate="pageDate"
               @on-page-change="queryData">
        <Table
                :data="datalist"
                :columns="columns1"
                slot="table"
                :loading="tableload"></Table>
        <orh-sidebar v-model="isShow" :title="titles" printer @on-printer="printingClick" cover slot="others">
            <information-detail v-if="isShow" :printstatus="printstatus" :teacher_id="teacher_id"
                                :user_id="user_id"></information-detail>
        </orh-sidebar>
    </orh-table>
</template>

<script>
    export default {
        layout: "menu",
        name: "teacher-teachercomprehensiveassessment",
        components: {
            InformationDetail: resolve => {
				require(["$m/Teacher/TeacherInformation/InformationDetail.vue"], resolve);
			}
        },
        data() {
            return {
                printstatus: false,
                isShow: false,
                titles: '',
                pageDate: {
                    total: 0,
                    current_page: 1,
                    per_page: 10
                },
                tableload: true,
                datalist: [],
                user_id: null,
                teacher_id: '',

                columns1: [
                    {
						title: '头像',
						width: 100,
						key: 'imgphotos',
						render: (h, params) => {
							return h('div', {
								attrs: {
									style: 'width: 80px;height: 80px;'
								},
							}, [
								h('img', {
									props: {
										type: 'primary',
										size: 'small'
									},
									attrs: {
										src: params.row.imgphotos != null ? params.row.imgphotos : 'http://1.180.78.87/dc/framework/common/images/noPic_150x150.jpg',
										style: 'width: 90%;height: 90%;border-radius: 2px;'
	
									},
									style: {},
								}),
							]);
						}
					},
                    {
                        title: '身份证号',
                        width: 180,
                        key: 'idcard'
                    },
                    {
                        title: '姓名',
                        width: 180,
                        render: (h, params) => {
                            return h('span', params.row.teacher_name !== null ? params.row.teacher_name ? params.row.teacher_name.zh ? params.row.teacher_name.zh : params.row.teacher_name.mn : '' : '未知')
                        }
                    },
                    {
                        title: '性别',
                        width: 60,
                        render: (h, params) => {
                            return h('span', params.row.gender !== null ? params.row.gender.zh ? params.row.gender.zh : params.row.gender.mn : "未知")
                        }
                    },
                    {
                        title: '民族',
                        width: 80,
                        render: (h, params) => {
                            return h('span', params.row.nation !== null ? params.row.nation.zh ? params.row.nation.zh : params.row.nation.mn : "未知")
                        }
                    },
                    {
                        title: '联系号码',
                        width: 120,
                        key: 'telnumber'
                    },
                    {
                        title: '邮箱',
                        width: 150,
                        key: 'email'
                    },
                    {
                        title: '在岗状态',
                        width: 100,
                        render: (h, params) => {
                            return h('span', params.row.workstatus !== null ? params.row.workstatus.zh ? params.row.workstatus.zh : params.row.workstatus.mn : "未知")
                        }
                    },
                    {
                        title: ' ',
                    },

                    {
                        title: '操作',
                        fixed: 'right',
                        width: 80,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'success',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px',
                                    },
                                    on: {
                                        click: () => {
                                            this.detail(params.row.id, params.row.teacher_id)
                                        }
                                    }
                                }, '查看'),

                            ]);
                        }
                    }
                ],

                searchValue: ''
            }
        },
        methods: {
            /************************************************************
             *
             * 请求列表数据
             *
             ************************************************************/
            queryData(page) {
				let url = ''
				if (this.searchValue) {
					let obj = {
						zh: this.searchValue
					}
					url = `api/teacher/information/getNoWorkList?page=${page}&limit=10&teacher_name=${JSON.stringify(obj)}`
				} else {
					url = `api/teacher/information/getNoWorkList?page=${page}&limit=10`
				}
				this.$http.get(url).then(val => {
					this.datalist = val.data
					this.pageDate.total = val.count
					this.pageDate.per_page = val.limit
					this.pageDate.current_page = val.page
					this.tableload = false
				}).catch(err => {
					this.tableload = false
				});
            },

            /************************************************************
             *
             * 点击查看
             *
             ************************************************************/
            detail(user_id, teacher_id) {
                this.isShow = true;
                this.titles = '详情';
                this.user_id = user_id;
                this.teacher_id = teacher_id;
            },

            /************************************************************
             *
             * 搜索
             *
             ************************************************************/
            searchmt(str) {
                this.searchValue = str
				this.queryData (1)
            },

            /************************************************************
             *
             * 刷新
             *
             ************************************************************/
            refresh(page) {
				this.searchValue = ''
				this.queryData (page)
            },

            // ==================================================
            // 打印
            // ==================================================
            printingClick() {
                this.printstatus = true
            },
        },
        watch: {
            'isShow': {
                handler() {
                    if (this.isShow == false) {
                        this.printstatus = false
                    }

                }
            },
        },
        mounted() {
            this.queryData(1)
        }
    }
</script>




